package cn.edu.answer.service.impl;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.edu.answer.dao.QuestionDao;
import cn.edu.answer.po.Question;
import cn.edu.answer.service.QuestionService;
import cn.edu.answer.utils.Page;

/**
 * 班级管理
 */
@Service("questionService")
@Transactional
public class QuestionServiceImpl implements QuestionService {
	// 声明DAO属性并注入
	@Autowired
	private QuestionDao questionDao;
	// 班级信息列表
	@Override
	public Page<Question> findQuestionList(Integer page, Integer rows) {
		// 创建班级对象
		Question question = new Question();

		// 当前页
		question.setStart((page-1) * rows) ;
		// 每页数
		question.setRows(rows);
		// 查询班级列表
		List<Question> questions = 
				questionDao.selectQuestionList(question);
		// 查询班级列表总记录数
		Integer count = questionDao.selectQuestionListCount(question);
		// 创建Page返回对象
		Page<Question> result = new Page<>();
		result.setPage(page);
		result.setRows(questions);
		result.setSize(rows);
		result.setTotal(count);
		return result;
	}
	@Override
	public int createQuestion(Question question) {
		// TODO Auto-generated method stub
		return questionDao.createQuestion(question);
	}
	@Override
	public Question getQuestionById(String qid) {
		// TODO Auto-generated method stub
		return questionDao.getQuestionById(qid);
	}
	@Override
	public int updateQuestion(Question question) {
		// TODO Auto-generated method stub
		return questionDao.updateQuestion(question);
	}
	@Override
	public int deleteQuestion(String qid) {
		// TODO Auto-generated method stub
		return questionDao.deleteQuestion(qid);
	}
	
	
	
	
}